package com.sz.mes.excel.model;

import java.util.Date;
import java.lang.Double;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.HeadStyle;
import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
import com.diboot.core.util.D;
import com.diboot.core.util.V;
import com.diboot.file.excel.BaseExcelModel;
import com.diboot.file.excel.annotation.ExcelBindDict;
import com.diboot.file.excel.annotation.ExcelBindField;
import com.diboot.file.excel.annotation.ExcelOption;
import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;

import com.sz.mes.entity.SaleOrder;

/**
 * 销售订单 导入model定义
 *
 * @author hem
 * @version 1.0
 * @date 2024-01-10
 * Copyright © szhs
 */
@Getter
@Setter
@ExcelIgnoreUnannotated
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 1)
public class SaleOrderImportModel extends BaseExcelModel {

    /**
     * 料品财务分类
     */
    @Length(max = 100, message = "料品财务分类长度应小于100")
    @ExcelProperty(value = "料品财务分类")
    private String materialFinancial;
    /**
     * 料号
     */
    @Length(max = 100, message = "料号长度应小于100")
    @ExcelProperty(value = "料号")
    private String productNum;
    /**
     * 客户简称
     */
    @Length(max = 100, message = "客户简称长度应小于100")
    @ExcelProperty(value = "客户简称")
    private String clientName;
    /**
     * 业务负责人
     */
    @Length(max = 100, message = "业务负责人长度应小于100")
    @ExcelProperty(value = "业务负责人")
    private String businessManager;
    /**
     * 订单号
     */
    @Length(max = 100, message = "订单号长度应小于100")
    @ExcelProperty(value = "订单号")
    private String orderNum;
    /**
     * 订单行号
     */
    @Length(max = 100, message = "订单行号长度应小于100")
    @ExcelProperty(value = "订单行号")
    private String orderRow;
    /**
     * 料品规格
     */
    @Length(max = 100, message = "料品规格长度应小于100")
    @ExcelProperty(value = "料品规格")
    private String specification;
    /**
     * 销售订单行.料品.料品.库存主单位
     */
    @Length(max = 100, message = "销售订单行.料品.料品.库存主单位长度应小于100")
    @ExcelProperty(value = "销售订单行.料品.料品.库存主单位")
    private String unit;
    /**
     * 料品名称
     */
    @Length(max = 255, message = "料品名称长度应小于255")
    @ExcelProperty(value = "料品名称")
    private String productName;
    /**
     * 订单数量
     */
    @ExcelProperty(value = "订单数量")
    private Integer orderQuantity;
    /**
     * 下单日期
     */
    @DateTimeFormat(D.FORMAT_DATE_Y4MD)
    @JsonFormat(pattern = D.FORMAT_DATE_Y4MD)
    @ExcelProperty(value = "下单日期")
    private Date buyDate;
    /**
     * 合同要求日期
     */
    @DateTimeFormat(D.FORMAT_DATE_Y4MD)
    @JsonFormat(pattern = D.FORMAT_DATE_Y4MD)
    @ExcelProperty(value = "合同要求日期")
    private Date contractDemandDate;
    /**
     * 未出货数量
     */
    @ExcelProperty(value = "未出货数量")
    private Integer unshippedGoodsQuantity;
    /**
     * 累计出货数量
     */
    @ExcelProperty(value = "累计出货数量")
    private Integer totalShipmentQuantity;
    /**
     * 客户采购员
     */
    @Length(max = 100, message = "客户采购员长度应小于100")
    @ExcelProperty(value = "客户采购员")
    private String clientPurchasePerson;
    /**
     * 客户使用人
     */
    @Length(max = 100, message = "客户使用人长度应小于100")
    @ExcelProperty(value = "客户使用人")
    private String clientUser;
    /**
     * 客户物料号
     */
    @Length(max = 100, message = "客户物料号长度应小于100")
    @ExcelProperty(value = "客户物料号")
    private String clientProductNum;
    /**
     * 客户图号
     */
    @Length(max = 100, message = "客户图号长度应小于100")
    @ExcelProperty(value = "客户图号")
    private String clientPicNum;
    /**
     * 客户工厂代码
     */
    @Length(max = 100, message = "客户工厂代码长度应小于100")
    @ExcelProperty(value = "客户工厂代码")
    private String clientFactoryCode;
    /**
     * 客户库位
     */
    @Length(max = 100, message = "客户库位长度应小于100")
    @ExcelProperty(value = "客户库位")
    private String clientLocation;
    /**
     * 物料描述
     */
    @Length(max = 255, message = "物料描述长度应小于255")
    @ExcelProperty(value = "物料描述")
    private String materialDescription;
    /**
     * 收货地址
     */
    @Length(max = 255, message = "收货地址长度应小于255")
    @ExcelProperty(value = "收货地址")
    private String deliveryAddress;
    /**
     * 订货客户.客户名称
     */
    @Length(max = 100, message = "订货客户.客户名称长度应小于100")
    @ExcelProperty(value = "订货客户.客户名称")
    private String customerName;

    //    /**
//     * excel内容
//     */
//    @Length(max=100, message="excel内容长度应小于100")
//    @ExcelProperty(value = "excel内容")
//    private String excelData;
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SaleOrderImportModel saleOrderImportModel = (SaleOrderImportModel) o;
        Boolean materialFinancialSame = true;
        Boolean productNumSame = true;
        Boolean clientNameSame = true;
        Boolean businessManagerSame = true;
        Boolean orderNumSame = true;
        Boolean orderRowSame = true;
        Boolean specificationSame = true;
        Boolean unitSame = true;
        Boolean productNameSame = true;
        Boolean orderQuantitySame = true;
        Boolean buyDateSame = true;
        Boolean contractDemandDateSame = true;
        Boolean unshippedGoodsQuantitySame = true;
        Boolean totalShipmentQuantitySame = true;
        Boolean clientPurchasePersonSame = true;
        Boolean clientUserSame = true;
        Boolean clientProductNumSame = true;
        Boolean clientPicNumSame = true;
        Boolean clientFactoryCodeSame = true;
        Boolean clientLocationSame = true;
        Boolean materialDescriptionSame = true;
        Boolean deliveryAddressSame = true;
        Boolean customerNameSame = true;

        if (materialFinancial != null) {
            materialFinancialSame = materialFinancial.equals(saleOrderImportModel.materialFinancial);
        }
        if (productNum != null) {
            productNumSame = productNum.equals(saleOrderImportModel.productNum);
        }
        if (clientName != null) {
            clientNameSame = clientName.equals(saleOrderImportModel.clientName);
        }
        if (businessManager != null) {
            businessManagerSame = businessManager.equals(saleOrderImportModel.businessManager);
        }
        if (orderNum != null) {
            orderNumSame = orderNum.equals(saleOrderImportModel.orderNum);
        }
        if (orderRow != null) {
            orderRowSame = orderRow.equals(saleOrderImportModel.orderRow);
        }
        if (specification != null) {
            specificationSame = specification.equals(saleOrderImportModel.specification);
        }
        if (unit != null) {
            unitSame = unit.equals(saleOrderImportModel.unit);
        }
        if (productName != null) {
            productNameSame = productName.equals(saleOrderImportModel.productName);
        }
        if (orderQuantity != null) {
            orderQuantitySame = orderQuantity.equals(saleOrderImportModel.orderQuantity);
        }
        if (buyDate != null) {
            buyDateSame = buyDate.equals(saleOrderImportModel.buyDate);
        }
        if (contractDemandDate != null) {
            contractDemandDateSame = contractDemandDate.equals(saleOrderImportModel.contractDemandDate);
        }
        if (unshippedGoodsQuantity != null) {
            unshippedGoodsQuantitySame = unshippedGoodsQuantity.equals(saleOrderImportModel.unshippedGoodsQuantity);
        }
        if (totalShipmentQuantity != null) {
            totalShipmentQuantitySame = totalShipmentQuantity.equals(saleOrderImportModel.totalShipmentQuantity);
        }
        if (clientPurchasePerson != null) {
            clientPurchasePersonSame = clientPurchasePerson.equals(saleOrderImportModel.clientPurchasePerson);
        }
        if (clientUser != null) {
            clientUserSame = clientUser.equals(saleOrderImportModel.clientUser);
        }
        if (clientProductNum != null) {
            clientProductNumSame = clientProductNum.equals(saleOrderImportModel.clientProductNum);
        }
        if (clientPicNum != null) {
            clientPicNumSame = clientPicNum.equals(saleOrderImportModel.clientPicNum);
        }
        if (clientFactoryCode != null) {
            clientFactoryCodeSame = clientFactoryCode.equals(saleOrderImportModel.clientFactoryCode);
        }
        if (clientLocation != null) {
            clientLocationSame = clientLocation.equals(saleOrderImportModel.clientLocation);
        }
        if (materialDescription != null) {
            materialDescriptionSame = materialDescription.equals(saleOrderImportModel.materialDescription);
        }
        if (deliveryAddress != null) {
            deliveryAddressSame = deliveryAddress.equals(saleOrderImportModel.deliveryAddress);
        }
        if (customerName != null) {
            customerNameSame = customerName.equals(saleOrderImportModel.customerName);
        }

        return materialFinancialSame && productNumSame && clientNameSame && businessManagerSame && orderNumSame && orderRowSame
                && specificationSame && unitSame && productNameSame && orderQuantitySame && buyDateSame && contractDemandDateSame
                && unshippedGoodsQuantitySame && totalShipmentQuantitySame && clientPurchasePersonSame && clientUserSame
                && clientProductNumSame && clientPicNumSame && clientFactoryCodeSame && clientLocationSame
                && materialDescriptionSame && deliveryAddressSame && customerNameSame;
    }


    @Override
    public int hashCode() {
        return Objects.hash(materialFinancial, productNum, clientName, businessManager, orderNum, orderRow,
                specification, unit, productName, orderQuantity, buyDate, contractDemandDate, unshippedGoodsQuantity,
                totalShipmentQuantity, clientPurchasePerson, clientUser, clientProductNum, clientPicNum,
                clientFactoryCode, clientLocation, materialDescription, deliveryAddress, customerName);
    }
}
